package com.dmm.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dmm.Exception.Exceptionbean;
import com.dmm.user.entity.Apply;
import com.dmm.user.mapper.ApplyMapper;
import com.dmm.user.service.ApplyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author com/dmm
 * @since 2023-04-03
 */
@Service
public class ApplyServiceImpl extends ServiceImpl<ApplyMapper, Apply> implements ApplyService {

    @Resource
    ApplyMapper applyMapper;

    //管理员申请
    @Override
    public void applyadmin(Apply apply) {
        QueryWrapper<Apply> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("email",apply.getEmail());
        try {

            Apply apply1 = applyMapper.selectOne(queryWrapper);

            if(apply1.getEmail().isEmpty()){
                throw new Exceptionbean(20001,"请勿重复申请");
            }
        }catch (Exception e){

            applyMapper.insert(apply);

        }

    }
}
